import openpyxl
from key_demo import Key


def new_data(value):
    data = {}
    if values[2] != None:
        str_temp = value.split(';')
        for temp in str_temp:
            temp = temp.split('=', 1)
            data[temp[0]] = temp[1]
    else:
        data = None
    return data


excel = openpyxl.load_workbook('demo2new.xlsx')

for name in excel.sheetnames:
    sheet = excel[name]
    for values in sheet.values:
        if type(values[0]) is int:
            data = new_data(values[2])
            print(data)


            # data = {}
            # data['name'] = values[2]
            # data['value'] = values[3]
            # data['txt'] = values[4]
            # for k in list(data.keys()):
            #     if data[k] is None:
            #         del data[k]
            if values[1] == 'open_browser':
                key = Key(**data)
            else:
                if data is not None:
                    getattr(key,values[1])(**data)
                else:
                    getattr(key,values[1])()